package org.example.mq;


import org.apache.rocketmq.common.message.MessageExt;

import javax.annotation.PostConstruct;

/**
 * @author: wf
 * @create: 2020/12/8 15:43
 * @description: 消费消息处理接口
 */
public abstract class ConsumerServer {
    //topic队列
    protected String topic;
    //过滤消息tags表达式
    protected String tagExp;
    
    /**
     * 初始化topic和tagExp
     */
    @PostConstruct
    public abstract void initConsumerMsg();
    
    /**
     * 消费者-消息处理接口
     *
     * @param messageExt
     * @return 返回false会进入重试
     */
    public abstract boolean receive(MessageExt messageExt);
    
    public final String getTopic() {
        return topic;
    }
    public final String getTagExp() {
        return tagExp;
    }
    public final void setTopic(String topic) {
        this.topic = topic;
    }
    public final void setTagExp(String tagExp) {
        this.tagExp = tagExp;
    }
}
